import { sm2 } from 'sm-crypto'
const publicKey = '04FBEBDF23AB2CDC8B96828BF71807A3C886B7E5BBC47487C3CB73F062DF6D5A3B5D053B420FC14028330F77030F53AE3736A75DF75C186421D1A34B30E33ADC6D'
// * - `0`：C1C2C3
// * - `1`：C1C3C2
enum SM2_CIPHER_MODE {
	C1C2C3 = 0,
	C1C3C2 = 1
}

/**
 * sm2加密
 * @param data 待加密数据
 * @return 加密后的数据
 */
export const sm2Encrypt = (data: string): string => {
	return '04' + sm2.doEncrypt(data, publicKey, SM2_CIPHER_MODE.C1C2C3)
}
